//
//  TMDataTable.h
//  clublbiza
//
//  Created by WANG TOM on 7/22/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "ITMTableCoreDataContectProvider.h"

@interface TMDataTable : NSObject
@property(copy,atomic) NSString *tableName;
@property(copy,atomic) NSString *pkName;
@property(assign,atomic) id<ITMTableCoreDataContectProvider> contextProvider;

@property(readonly,atomic) NSManagedObjectContext *dbContext;
-(TMDataTable *) initWithTablename:(NSString *)p_tableName withPKName:(NSString *)p_pkName contextProvider:(id<ITMTableCoreDataContectProvider>)p_contextProvider;
-(NSArray *) findAll:(NSString *)condition withSort:(NSString *)sort;
-(NSManagedObject *) find:(NSString *) pkName;
-(NSManagedObject *) findByField:(NSString *)fieldName withValue:(id)fieldValue withSort:(NSString*)sort;
-(void) addRow:(NSDictionary *)dataRow;
-(void) addRows:(NSArray *)dataRows;
-(void) saveRow:(NSDictionary *)dataRow;
-(void) saveRows:(NSArray *)dataRows;
-(void) deleteRow:(NSString *) pkValue;
-(void) deleteAll;
@end
